<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="App-Config" content="fullscreen=yes,useHistoryState=yes,transition=yes" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="yes" name="apple-touch-fullscreen" />
		<meta content="telephone=no,email=no" name="format-detection" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>添加成员</title>
		<link href="../c/adduser.css" rel="stylesheet" />
	</head>
	<style>
		.tit{
		  width: 50%;
		   margin: 0.5rem 0;
		  margin-left: 25%;
		  overflow: auto;
		 
	  }
	  .tit span{
		  display: block;
		  width: 50%;
		  float: left;
		  height: 2rem;
	  }
	  .tit small{
		  display: block;
		  
	  }
	  .tit small:nth-of-type(1){
		  color: #A6A2A2;
		  margin-bottom: 0.5rem;
		  text-align: center;
		  font-size: 0.875rem;
	  }
	  .tit small:nth-of-type(2){
		  height:2px;
		  width: 20%;
		margin-left: 40%;
		background: #FE2C55;
		border-radius: 2px;
	  }
	  .tit span:nth-of-type(2) small:nth-of-type(1){
		  color: #FFFFFF;
	  }
	  .sou{
		  width: 94%;
		  height: 2rem;
		  background: #2E2C39;
		  margin-left: 3%;
		  border-radius: 2rem;
	  }
	  .sou img{
		  width: 0.9375rem;
		  margin-left: 1.0625rem;
		  float: left;
		  margin-top: 0.65rem;
	  }
	  .sou input{
		  height: 100%;
		  border: none;
		  outline: none;
		  width: 80%;
		  float: left;
		  color: #fff;
		  margin-left: 5%;
		  background: none;
	  }
  </style>
	<body>
		<p class="tit"><span><small>添加好友</small><small style="display: none;"></small></span><span><small>我的好友</small><small></small></span></p>
		<p class="sou"><img src="../i/sou.png"><input type="text" placeholder="搜索用户名/ID号/手机号"></p>
		<div class="userList">
			<div class="user_list">
				<p></p>
				<p>测试1</p>
				<p class="yq">邀请加入</p>
				<p>用户等级:普通会员</p>
				<p>注册时间:2020-12-25 16:42:18</p>
			</div>
			<div class="user_list">
				<p></p>
				<p>测试1</p>
				<p class="yq">邀请加入</p>
				<p>用户等级:普通会员</p>
				<p>注册时间:2020-12-25 16:42:18</p>
			</div>
			<div class="user_list">
				<p></p>
				<p>测试1</p>
				<p class="yyq">已邀请<br>等待对方加入</p>
				<p>用户等级:普通会员</p>
				<p>注册时间:2020-12-25 16:42:18</p>
			</div>
		</div>
	</body>

</html>
<script type="text/javascript" src="../j/api.js"></script>
<script src="../j/jquery-3.3.1.min.js"></script>
<script>
	//邀请
	function addusera(addid, userid, i) {
		var url = "agent/invite?token=" + userid + "&uid=" + addid + "";
		var tex = $(".user_list").eq(i).children(".yq").text();
		if (tex != "邀请加入") {
			_msg("请勿多次点击邀请");
			return;
		}
		$(".user_list").eq(i).children(".yq").text("点击邀请");
		_ajax1(url, function(ret, status) {
			if (ret) {
				// $(".user_list").eq(i).children(".yq").html("已邀请<br>等待对方加入");
				// $(".user_list").eq(i).children(".yq").addClass("yyq");
				if (ret.err) {
					_msg(JSON.stringify(ret.err));
					return;
				}
				$(".user_list").eq(i).children(".yq").html("已邀请<br>等待对方加入");
				$(".user_list").eq(i).children(".yq").addClass("yyq");
			} else {
				_msg(JSON.stringify(err))
			}
		})
	}
	apiready = function() {
		var _user = _getPrefs('_user');
		_ajax1("agent/waitInviteList", function(ret, status) {
			if (ret) {
				var str = '';
				for (var i = 0; i < ret.ret.length; i++) {
					str += ' <div class="user_list">';
					if (ret.ret[i].img == null || ret.ret[i].img == "null") {
						str += '  <p style="overflow: hidden;"><img src="' + picurl + '/redian-img-zan.png" style="width:100%;"></p>';
					} else {
						str += '  <p style="overflow: hidden;"><img src="' + _img(ret.ret[i].img) + '" style="width:100%;"></p>';
					}

					str += '  <p>' + ret.ret[i].nickname + '</p>';
					if (ret.ret[i].is_invite == 0 || ret.ret[i].is_invite == "0") {
						str += ' <p class="yq" onclick="addusera(' + ret.ret[i].id + ',' + _user.id + ',' + i + ')">邀请加入</p>';
					} else if (ret.ret[i].is_invite == 1 || ret.ret[i].is_invite == "1") {
						str += ' <p class="yyq" >已邀请<br>等待对方加入</p>';
					} else if (ret.ret[i].is_invite == 2 || ret.ret[i].is_invite == "2") {
						str += ' <p class="yyq">已通过</p>';
					} else if (ret.ret[i].is_invite == 3 || ret.ret[i].is_invite == "3") {
						str += ' <p class="yyq">已拒绝</p>';
					}
					str += ' <p>用户等级:';
					if (ret.ret[i].levels == 0 && ret.ret[i].agent == 0) {
						str += '普通';
					} else if (ret.ret[i].agent == 1 && ret.ret[i].levels == 0) {
						str += '达人';
					} else if (ret.ret[i].agent == 1 && ret.ret[i].levels == 1) {
						str += '工会';
					} else if (ret.ret[i].agent == 1 && ret.ret[i].levels == 2) {
						str += '机构';
					}
					str += '</p>';
					str += '<p>注册时间:';
					var date = new Date(Number(ret.ret[i].create_time + "000")); //将接收到的的String类型的时间转为数字类型
					var y = date.getFullYear();
					var m = date.getMonth() + 1;
					var d = date.getDate();
					var hour = date.getHours().toString();
					var minutes = date.getMinutes().toString();
					var seconds = date.getSeconds().toString();
					var time = y + "-" + m + "-" + d + "&nbsp;&nbsp" + hour + ":" + minutes + ":" + seconds;
					str += '' + time + '</p>';
					str += ' </div>';
				}
				if (str == '') {
					$(".userList").html('<p style="text-align: center;color:#fff;margin-top:1rem">暂无数据!</p>');

				} else {
					$(".userList").html(str);
				}
			} else {
				$(".userList").html('<p style="text-align: center;color:#fff;margin-top:1rem">暂无数据!</p>');
			}
		})
	}
</script>
